#include "progset.h"
#include "ui_progset.h"
#include "mainWidget.h"

ProgSet::ProgSet(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ProgSet)
{
    ui->setupUi(this);

    pWidget = static_cast<Widget*>(parent);

    ui->stackedWidget->setCurrentIndex(ProgMgt_id);

    //返回设置子界面
    connect(ui->Btn_back1, &QPushButton::clicked, this, [=](){
        pWidget->backSetPage();
    });
    //返回编程子界面
    connect(ui->Btn_back5, &QPushButton::clicked, this, [=](){
        pWidget->backTeachPage();
    });

    connect(ui->Btn_USBcopy, &QPushButton::clicked, this, [=](){
        ui->stackedWidget->setCurrentIndex(CopySel_id);
    });
    connect(ui->Btn_back2, &QPushButton::clicked, this, [=](){
        ui->stackedWidget->setCurrentIndex(ProgMgt_id);
    });
    connect(ui->Btn_back3, &QPushButton::clicked, this, [=](){
        ui->stackedWidget->setCurrentIndex(CopySel_id);
    });
    connect(ui->Btn_back4, &QPushButton::clicked, this, [=](){
        ui->stackedWidget->setCurrentIndex(CopySel_id);
    });
    connect(ui->Btn_ok, &QPushButton::clicked, this, [=](){
        ui->stackedWidget->setCurrentIndex(ProgMgt_id);
    });
    connect(ui->Btn_CtoU, &QPushButton::clicked, this, [=](){
        ui->stackedWidget->setCurrentIndex(CtoU_id);
    });
    connect(ui->Btn_UtoC, &QPushButton::clicked, this, [=](){
        ui->stackedWidget->setCurrentIndex(UtoC_id);
    });
}

ProgSet::~ProgSet()
{
    delete ui;
}

//提供给编程界面的程序选择按钮来跳转
void ProgSet::showProgSelPage()
{
    ui->stackedWidget->setCurrentIndex(ProgSel);
}
